I try to cast a string to time span but i get the following exception :
Input string was not in a correct format.
My code :
rad_from_time.SelectedTime = TimeSpan.Parse(pro[0].FromTime)
pro[0].FromTime = "1:00 AM";
Home / DeveloperSection / Forums / How to parse string contains time of day in c#?
I try to cast a string to time span but i get the following exception :
Input string was not in a correct format.
My code :
rad_from_time.SelectedTime = TimeSpan.Parse(pro[0].FromTime)
pro[0].FromTime = "1:00 AM";
Manoj Bhatt
11-Nov-2014Try this:
rad_from_time.SelectedTime = DateTime.ParseExact(pro[0].FromTime, "h:mm tt", CultureInfo.InvariantCulture).TimeOfDay;